package top.xia17.plugins.fast.quartz.api.entity;

import cn.hutool.core.bean.BeanUtil;
import top.xia17.plugins.fast.common.database.jpa.extension.BaseUserTimeEntity;
import top.xia17.plugins.fast.common.database.jpa.extension.JpaEntity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.xia17.plugins.fast.quartz.core.QuartzJobInfo;

import jakarta.persistence.*;
import java.io.Serializable;

/**
 * quartz定时任务表(QuartzJob)实体类
 *
 * @author xia17
 * @since 2022-06-13 17:29:10
 */
@Entity
@Table(name = "sys_quartz_job")
@Accessors(chain = true)
@Getter
@Setter
@NoArgsConstructor
public class QuartzJob extends BaseUserTimeEntity implements JpaEntity<Long>, Serializable {
    private static final long SERIAL_VERSION_UID = 667242333087162937L;

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * uuid
     */
    private String uuid;

    /**
     * 任务名
     */
    private String jobName;

    /**
     * SpringBean名称
     */
    private String beanName;

    /**
     * 方法名称
     */
    private String methodName;

    /**
     * 参数
     */
    private String param;

    /**
     * cron表达式
     */
    private String cron;

    /**
     * 是否暂停
     */
    private Boolean isPause;

    /**
     * 负责人
     */
    private String personInCharge;

    /**
     * 报警邮箱
     */
    private String alarmEmail;

    /**
     * 子任务
     */
    private String subTask;

    /**
     * 失败后是否暂停
     */
    private Boolean pauseAfterFailure;

    /**
     * 备注
     */
    private String remark;


    public QuartzJobInfo toQuartzJobInfo() {
        QuartzJobInfo quartzJobInfo = new QuartzJobInfo();
        BeanUtil.copyProperties(this, quartzJobInfo);
        return quartzJobInfo;
    }


}

